package xkp.lesson4;

import java.io.Serializable;

public class Driver implements Serializable {
    private Integer age;
    private String name;
    private Car car;
    //加入司机有老婆、教练、老板、宠物

    public Driver() {
    }

    public Driver(Integer age, String name, Car car) {
        this.age = age;
        this.name = name;
        this.car = car;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Car getCar() {
        return car;
    }

    public void setCar(Car car) {
        this.car = car;
    }

    @Override
    public String toString() {
        return "Driver{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", car=" + car +
                '}';
    }

   /* @Override
    public Object clone() throws CloneNotSupportedException {
        //此处创建的obj是this对象的副本
        //此时obj本质上是一个Driver对象，此时obj中的车和this中的车是一辆车,此处依然是浅拷贝
        Driver obj = (Driver) super.clone();
        //this
        //把车重新克隆一份
        //obj指向新车，实现了深拷贝
        obj.car = (Car) this.car.clone();
        return obj;
    }*/
}
